package com.szml.listener;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author limin
 * @date 2025-06-17 16:25
 * @description
 */
@Component
@RocketMQMessageListener(topic = "bootTagTopic",
        consumerGroup = "boot-tag-consumer-group",
        selectorType = SelectorType.TAG, //tag过滤模式
        //selectorType = SelectorType.SQL92, //SQL92过滤模式  "topic:tag" => "topic:3"  > < 等来过滤消息
        //但默认SQL92模式是不支持的，要使用的话，要在broker里面配置开启才行
        selectorExpression = "tagA || tagB"
)
public class CTagMsgListener implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt message){
        System.out.println(new String(message.getBody()));//我是一个带tag的消息

    }
}
